package 华为OD机试真题2023.基础题;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class HJ45_光伏场地建设规划 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/基础题/input/45.txt"));
        int x, y, n, power;
        x = in.nextInt();
        y = in.nextInt();
        n = in.nextInt();
        power = in.nextInt();
        int[][] matrix = new int[x][y];
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                matrix[i][j] = in.nextInt();
            }
        }
        int res = 0;
        for (int i = 0; i <= x - n; i++) {
            for (int j = 0; j <= y - n; j++) {
                if (isMatch(matrix, i, j, n, power)) {
                    res++;
                }
            }
        }
        System.out.println(res);
    }

    static boolean isMatch(int[][] matrix, int x, int y, int n, int power) {
        int cnt = 0;
        for (int i = x; i < x + n; i++) {
            for (int j = y; j < y + n; j++) {
                cnt += matrix[i][j];
            }
        }
        return cnt >= power;
    }
}
